<?php
require_once("vcl/vcl.inc.php");
require_once("lib/db_connection.php");
//Includes
use_unit("platinumgrid/jtplatinumgrid.inc.php");
use_unit("components4phpfull/jtpagecontrol.inc.php");
use_unit("components4phpfull/jtsitetheme.inc.php");
use_unit("forms.inc.php");
use_unit("extctrls.inc.php");
use_unit("stdctrls.inc.php");

//Class definition
class fuel_frame extends Page
{
       public $Label4 = null;
       public $lblyearmakemodel = null;
       public $Label1 = null;
       public $imgBack = null;
       public $imgAddExpense = null;
       public $imgAddMaintenance = null;
       public $imgAddFuel = null;
       public $JTPlatinumFuel = null;
       public $JTPlatinumMaintenance = null;
       public $JTPlatinumExpense = null;
       public $hiddenId = null;
       public $lblVeh = null;
       public $Label2 = null;
       public $JTPageControl1 = null;
       public $JTSiteTheme1 = null;
       function imgBackJSMouseOut($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.images['imgBack'].src="image/back.png"
       <?php

       }

       function imgBackJSMouseOver($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.images['imgBack'].src="image/back2.png"
       <?php

       }

       function imgAddExpenseJSMouseOut($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.images['imgAddExpense'].src="image/add_new.png"
       <?php

       }

       function imgAddExpenseJSMouseOver($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.images['imgAddExpense'].src="image/add_new_blue.png"
       <?php

       }

       function imgAddMaintenanceJSMouseOut($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.images['imgAddMaintenance'].src="image/add_new.png"
       <?php

       }

       function imgAddMaintenanceJSMouseOver($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.images['imgAddMaintenance'].src="image/add_new_blue.png"
       <?php

       }

       function imgAddFuelJSMouseOut($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.images['imgAddFuel'].src="image/add_new.png"
       <?php

       }

       function imgAddFuelJSMouseOver($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.images['imgAddFuel'].src="image/add_new_blue.png"
       <?php

       }

       function edtSearchExpenseJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.getElementById('edtSearchExpense').value = '';

       <?php

       }

       function edtSearchFuelJSClick($sender, $params)
       {

       ?>
       //Add your javascript code here
       document.getElementById('edtSearchFuel').value = '';

       <?php

       }



       function JTPlatinumExpenseShow($sender, $params)
       {
       $veh_id = $this->hiddenId->getValue();
       $query_expense = "select * from veh_expense_tbl where vehicle_id='".$veh_id."'";
       $result_expense = mysql_query($query_expense)or die(mysql_error());

       $arr = array();
       while($row_expense = mysql_fetch_array($result_expense))
       {

       $date = "<a href=veh_expense_edit.php?veh=".$veh_id."&expense=".$row_expense['payment_id'].">".$row_expense['date']."</a>";


       $arr[] = array(
                        'Date' => $date,
                        'Type' => $row_expense['type'],
                        'Description' => $row_expense['description'],
                        'Amt' => $row_expense['amount']
                        );
       }

       $this->JTPlatinumExpense->setCellData($arr);


       }



       function fuel_frameCreate($sender, $params)
       {
       $id = $_GET['veh'];
       $this->hiddenId->setValue($id);

       $result_vin = mysql_query("SELECT * FROM vehicle_tbl WHERE vehicle_id='".$this->hiddenId->getValue()."'")
       or die(mysql_error());
       $row_selected = mysql_fetch_array($result_vin);
       $label = $row_selected['VIN'];
       $ymm = $row_selected['year'].' '.$row_selected['manufacturer_name'].' '.$row_selected['model_name'];
       $this->lblVeh->Caption = $label;
       $this->lblyearmakemodel->Caption = $ymm;

       $this->imgBack->setLink('vehicle_list.php?company_id='.$_SESSION['company_id']);
       $this->imgAddFuel->setLink("veh_fuel_create.php?veh=".$this->hiddenId->getValue());
       $this->imgAddExpense->setLink("veh_expense_create.php?veh=".$this->hiddenId->getValue());
       $this->imgAddMaintenance->setLink("veh_workorder_create.php?veh=".$this->hiddenId->getValue());


       }

       function JTPlatinumFuelShow($sender, $params)
       {
       $veh_id = $this->hiddenId->getValue();
       $query_fuel = "select * from veh_fuel_tbl where vehicle_id='".$veh_id."'";
       $result_fuel = mysql_query($query_fuel)or die(mysql_error());

       $arr = array();
       while($row_fuel = mysql_fetch_array($result_fuel))
       {

         $date = "<a href=veh_fuel_edit.php?veh=".$veh_id."&fuel=".$row_fuel['fuel_id'].">".$row_fuel['date']."</a>";

         $arr[] = array(
                        'Date' => $date,
                        'Last Od' => $row_fuel['last_odometer'],
                        'Curr Od' => $row_fuel['present_odometer'],
                        'Miles' => $row_fuel['miles'],
                        'Gallons' => $row_fuel['gallons'],
                        'Tot Cost' => $row_fuel['tot_cost'],
                        'Brand' => $row_fuel['brand']
                        );


       }

       $this->JTPlatinumFuel->setCellData($arr);



       }

}

global $application;

global $fuel_frame;

//Creates the form
$fuel_frame=new fuel_frame($application);

//Read from resource file
$fuel_frame->loadResource(__FILE__);

//Shows the form
$fuel_frame->show();

?>